package engine.graphics.particles
{
	import engine.math.*;
	
	public class RxParticleEmitterParams
	{
		public var m_lifeTime:Number;
		public var m_halfLife:Number;
		public var m_timeOffset:Number;
		public var m_emitRate:Number;
		public var m_repeat:Boolean;
		public var m_velocity:RxVector4;
		public var m_acceleration:RxVector4;
		public var m_dampening:Number;
		public var m_angle:Number;
		public var m_angularVel:Number;
		public var m_angularAccel:Number;
		public var m_randTime:Number;
		public var m_randPos:RxVector4;
		public var m_randVel:RxVector4;
		public var m_randAngle:Number;
		public var m_randAngularVel:Number;
		public var m_randScale:Number;
		public var m_randColor:RxVector4;
		public var m_trailLength:uint;
		public var m_trailTime:Number;
		
		public function RxParticleEmitterParams()
		{
			this.m_lifeTime = 0;
			this.m_halfLife = 0;
			this.m_timeOffset = 0;
			this.m_emitRate = 0;
			this.m_repeat = false;
			this.m_velocity = new RxVector4();
			this.m_acceleration = new RxVector4();
			this.m_dampening = 0;
			this.m_angle = 0;
			this.m_angularVel = 0;
			this.m_angularAccel = 0;
			this.m_randTime = 0;
			this.m_randPos = new RxVector4();
			this.m_randVel = new RxVector4();
			this.m_randAngle = 0;
			this.m_randAngularVel = 0;
			this.m_randScale = 0;
			this.m_randColor = new RxVector4();
			this.m_trailLength = 0;
			this.m_trailTime = 0;
		}
		
		public function Delete() : void
		{
			this.m_velocity = null;
			this.m_acceleration = null;
			this.m_randPos = null;
			this.m_randVel = null;
			this.m_randColor = null;
		}
		
		public function ParseFromXML(xml:XMLList) : void
		{
			this.m_lifeTime = xml.@lifeTime;
			this.m_halfLife = xml.@halfLife;
			this.m_timeOffset = xml.@timeOffset;
			this.m_emitRate = xml.@emitRate;
			this.m_repeat = xml.@repeat == "1";
			this.m_velocity.CopyFromString(xml.@vel);
			this.m_acceleration.CopyFromString(xml.@accel);
			this.m_dampening = 1 / Math.max(0.01, xml.@dampening);
			this.m_angle = xml.@angle * (Math.PI / 180);
			this.m_angularVel = xml.@angularVel * (Math.PI / 180);
			this.m_angularAccel = xml.@angularAccel * (Math.PI / 180);
			this.m_randTime = xml.@randTime;
			this.m_randPos.CopyFromString(xml.@randPos);
			this.m_randVel.CopyFromString(xml.@randVel);
			this.m_randAngle = xml.@randAngle * (Math.PI / 180);
			this.m_randAngularVel = xml.@randAngularVel * (Math.PI / 180);
			this.m_randScale = xml.@randScale;
			this.m_randColor.CopyFromString(xml.@randColor);
			this.m_trailLength = xml.@trailLength;
			this.m_trailTime = xml.@trailTime;
		}
	}
}